package gui;

import java.awt.Color;

import javax.swing.*;

import gameBasicElements.PlayerColor;

/**
 * @author Wojciech Łopata
 *
 */

public class CurrentPlayerInfoPanel extends JPanel
{
	private static final long serialVersionUID = -4521687876894460171L;
	private final JLabel titleLabel;
	private final JLabel currentPlayerLabel;
    
	public CurrentPlayerInfoPanel()
	{
		titleLabel = new JLabel("Aktualny gracz: ");
		currentPlayerLabel = new JLabel();
		initComponents();
	}
	
	public void updatePlayerColor(PlayerColor color)
	{
		if(color == null)
		{
			currentPlayerLabel.setText("-");
			currentPlayerLabel.setForeground(Color.black);
			return;
		}
		switch(color)
		{
			case BLACK:
				currentPlayerLabel.setText("CZARNE");
				currentPlayerLabel.setForeground(Color.black);
				break;
			case WHITE:
				currentPlayerLabel.setText("BIAŁE");
				currentPlayerLabel.setForeground(Color.white);
				break;
		}
	}
	
    private void initComponents()
    {
        titleLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);

        currentPlayerLabel.setBackground(java.awt.SystemColor.activeCaptionBorder);
        currentPlayerLabel.setFont(new java.awt.Font("SansSerif", 1, 36)); // NOI18N
        currentPlayerLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(currentPlayerLabel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 198, Short.MAX_VALUE)
                    .addComponent(titleLabel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 198, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(titleLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(currentPlayerLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 49, Short.MAX_VALUE)
                .addContainerGap())
        );
    }
}
